/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model.db;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author mwiatrowski
 */
@Entity
@Table(name = "PROJECTS")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Projects.findAll", query = "SELECT p FROM Projects p"),
    @NamedQuery(name = "Projects.findByIdProjects", query = "SELECT p FROM Projects p WHERE p.idProjects = :idProjects"),
    @NamedQuery(name = "Projects.findByAuthor", query = "SELECT p FROM Projects p WHERE p.author = :author"),
    @NamedQuery(name = "Projects.findByDateExists", query = "SELECT p FROM Projects p WHERE p.dateExists = :dateExists"),
    @NamedQuery(name = "Projects.findByDateFrom", query = "SELECT p FROM Projects p WHERE p.dateFrom = :dateFrom"),
    @NamedQuery(name = "Projects.findByDateTo", query = "SELECT p FROM Projects p WHERE p.dateTo = :dateTo"),
    @NamedQuery(name = "Projects.findByDescription", query = "SELECT p FROM Projects p WHERE p.description = :description"),
    @NamedQuery(name = "Projects.findByGroupId", query = "SELECT p FROM Projects p WHERE p.groupId = :groupId"),
    @NamedQuery(name = "Projects.findByName", query = "SELECT p FROM Projects p WHERE p.name = :name")})
public class Projects implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @Column(name = "ID_PROJECTS")
    private BigDecimal idProjects;
    @Column(name = "AUTHOR")
    private String author;
    @Column(name = "DATE_EXISTS")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateExists;
    @Column(name = "DATE_FROM")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateFrom;
    @Column(name = "DATE_TO")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateTo;
    @Column(name = "DESCRIPTION")
    private String description;
    @Column(name = "GROUP_ID")
    private String groupId;
    @Column(name = "NAME")
    private String name;
    @OneToMany(mappedBy = "idProjects")
    private Collection<ProjectsHistory> projectsHistoryCollection;

    public Projects() {
    }

    public Projects(BigDecimal idProjects) {
        this.idProjects = idProjects;
    }

    public BigDecimal getIdProjects() {
        return idProjects;
    }

    public void setIdProjects(BigDecimal idProjects) {
        this.idProjects = idProjects;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public Date getDateExists() {
        return dateExists;
    }

    public void setDateExists(Date dateExists) {
        this.dateExists = dateExists;
    }

    public Date getDateFrom() {
        return dateFrom;
    }

    public void setDateFrom(Date dateFrom) {
        this.dateFrom = dateFrom;
    }

    public Date getDateTo() {
        return dateTo;
    }

    public void setDateTo(Date dateTo) {
        this.dateTo = dateTo;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getGroupId() {
        return groupId;
    }

    public void setGroupId(String groupId) {
        this.groupId = groupId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @XmlTransient
    public Collection<ProjectsHistory> getProjectsHistoryCollection() {
        return projectsHistoryCollection;
    }

    public void setProjectsHistoryCollection(Collection<ProjectsHistory> projectsHistoryCollection) {
        this.projectsHistoryCollection = projectsHistoryCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idProjects != null ? idProjects.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Projects)) {
            return false;
        }
        Projects other = (Projects) object;
        if ((this.idProjects == null && other.idProjects != null) || (this.idProjects != null && !this.idProjects.equals(other.idProjects))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.db.Projects[ idProjects=" + idProjects + " ]";
    }
    
}
